package com.platform.module.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.platform.common.core.text.Convert;
import com.platform.module.domain.LinkSubConcentrator;
import com.platform.module.mapper.LinkSubConcentratorMapper;
import com.platform.module.service.ILinkSubConcentratorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Arrays;
import java.util.List;

/**
 * 地址和集中器关联Service业务层处理
 * 
 * @author wangqi
 * @date 2020-08-01
 */
@Service
public class LinkSubConcentratorServiceImpl extends ServiceImpl<LinkSubConcentratorMapper,LinkSubConcentrator> implements ILinkSubConcentratorService
{
    @Autowired
    private LinkSubConcentratorMapper linkSubConcentratorMapper;

    /**
     * 查询地址和集中器关联列表
     * 
     * @param linkSubConcentrator 地址和集中器关联
     * @return 地址和集中器关联
     */
    @Override
    public List<LinkSubConcentrator> selectLinkSubConcentratorList(LinkSubConcentrator linkSubConcentrator)
    {
        return linkSubConcentratorMapper.selectLinkSubConcentratorList(linkSubConcentrator);
    }

    /**
     * 新增地址和集中器关联
     * 
     * @param linkSubConcentrator 地址和集中器关联
     * @return 结果
     */
    @Override
    public int insertLinkSubConcentrator(LinkSubConcentrator linkSubConcentrator)
    {
        return linkSubConcentratorMapper.insert(linkSubConcentrator);
    }

    /**
     * 修改地址和集中器关联
     * 
     * @param linkSubConcentrator 地址和集中器关联
     * @return 结果
     */
    @Override
    public int updateLinkSubConcentrator(LinkSubConcentrator linkSubConcentrator)
    {
        linkSubConcentratorMapper.delete(new QueryWrapper<LinkSubConcentrator>().eq("concentrator_id", linkSubConcentrator.getConcentratorId()));
        return linkSubConcentratorMapper.insert(linkSubConcentrator);
    }

    /**
     * 删除地址和集中器关联对象
     * 
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteLinkSubConcentratorByIds(String ids)
    {
        return linkSubConcentratorMapper.deleteBatchIds(Arrays.asList(Convert.toStrArray(ids)));
    }

    /**
     * 删除地址和集中器关联信息
     * 
     * @param concentratorId 地址和集中器关联ID
     * @return 结果
     */
    @Override
    public int deleteLinkSubConcentratorById(String concentratorId)
    {
        return linkSubConcentratorMapper.deleteById(concentratorId);
    }
}
